java.lang.ObjectCar
public class Car
Seat models a seat in a car in a passenger train.
| Field Summary | |
|---|---|
static double |
BUSINESS_SEAT_COST
The cost of a business class seat, in dollars. |
static int |
BUSINESS_SEATS
The number of seats in a business class car. |
static double |
ECONOMY_SEAT_COST
The cost of an economy class seat, in dollars. |
static int |
ECONOMY_SEATS
The number of seats in an economy class car. |
| Constructor Summary | |
|---|---|
Car(int carId,
boolean isBusinessClass)
Constructs a new Car object with the specified id. |
|
| Method Summary | |
|---|---|
boolean |
bookNextSeat()
Attempts to book a seat. |
boolean |
cancelSeat(int seatNo)
Cancels the booking for the specified seat, which must be between 1 and the maximum number of seats in the car. |
int |
id()
|
boolean |
isBusinessClass()
Returns true if this is a business-class car, false if this is an economy-class car. |
Seat[] |
seats()
Returns this car's list of seats. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double BUSINESS_SEAT_COST
public static final int BUSINESS_SEATS
public static final double ECONOMY_SEAT_COST
public static final int ECONOMY_SEATS
| Constructor Detail |
|---|
public Car(int carId,
boolean isBusinessClass)
carId: - cars identifierisBusinessClass: - is the seat business class or economy class| Method Detail |
|---|
public boolean bookNextSeat()
public boolean cancelSeat(int seatNo)
seatNo: - number of the seat
public int id()
public boolean isBusinessClass()
public Seat[] seats()